<?php

namespace WoXuanWang\Video\Repositories;

use WoXuanWang\Video\Models\Compilation;
use zgldh\Scaffold\BaseRepository;

class CompilationRepository extends BaseRepository
{
    /**
     * @var array
     */
    protected $fieldSearchable = [
        'title',
        'description',
        'visible_purview',
        'released_at',
        'funding_id'
    ];

    /**
     * Configure the Model
     **/
    public function model()
    {
        return Compilation::class;
    }

    public function create(array $attributes)
    {
        $compilation = parent::create($attributes); // TODO: Change the autogenerated stub
        $compilation->tags()->sync($attributes['tags']);
        return $compilation;
    }

    public function update(array $attributes, $id)
    {
        $compilation = parent::update($attributes,$id); // TODO: Change the autogenerated stub
        $compilation->tags()->sync($attributes['tags']);
        return $compilation;
    }
}
